 import Vue from 'vue'
 import axios from 'axios'
 Vue.prototype.$http = axios

 import {loadToken} from 'common/js/cache.js'

// 超时时间
 axios.defaults.timeout = 5000
 axios.defaults.baseURL = process.env.BASE_URL
 // axios.defaults.baseURL = 'http://10.0.0.2'
 let token = loadToken()

// http请求拦截器
 axios.interceptors.request.use(config => {
   if (token) {
     config.headers.Authorization = `Bearer ${loadToken()}`
   }
   return config
 }, error => {
   return error
  //  return Promise.reject(error)
 })
// http响应拦截器
 axios.interceptors.response.use(data => {
   return data
 }, error => {
   return error
  //  return Promise.reject(error)
 })

 export default axios
